 package com.cxl.other.view;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.net.ServerSocket;
 import java.net.Socket;
 
 public class Server extends Thread
 {
   private Socket socket;
 
   public Server(Socket socket)
   {
     this.socket = socket;
   }
   public void run() { try { BufferedReader in = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
       PrintWriter out = new PrintWriter(this.socket.getOutputStream());
       String str;
       do {
         str = in.readLine();
         System.out.println(str);
         out.println("我是服务器" + str);
         out.flush();
       }while (!"exit".equals(str));
     }
     catch (IOException e)
     {
       e.printStackTrace();
     } }
 
   public static void main(String[] arg)
   {
     try {
       ServerSocket ss = new ServerSocket(8888);
       while (true) {
         Server server = new Server(ss.accept());
         server.start();
       }
     }
     catch (IOException e) {
       e.printStackTrace();
     }
   }
 }

/* Location:           E:\work\eclipse3.6_\workspace\design_pattern\
 * Qualified Name:     com.cxl.other.view.Server
 * JD-Core Version:    0.6.1
 */